package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/*
 * 向文件中写入文本数据
 */
public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        //向文件fos.txt中写入字符串
        //默认为覆盖模式，append设为true为追加模式
        FileOutputStream fos = new FileOutputStream("./fos.txt",true);
//        String line = "爱你孤身走暗巷";
        String line = "";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        fos.close();
    }
}
